import 'package:demo202112/photo_app.dart';
import 'package:demo202112/stateful_group_page.dart';
import 'package:demo202112/wy_shows.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

import 'MyNaviPage/my_one_page.dart';


/**
 * @Author wywinstonwy
 * @Date 2022/1/4 9:12 下午
 * @Description:
 */

getMaterialApp(){
  return MaterialApp(
    title: 'flutter',
    onGenerateTitle: (context){
      var local = Localizations.localeOf(context);
      if(local.languageCode=='zh'){
        return 'flutter 学习';
      }
      return 'flutter study';
    },
    theme: ThemeData(primaryColor: Colors.blue),
    darkTheme: ThemeData(primaryColor: Colors.yellow),
    themeMode: ThemeMode.dark,
    home: OnePage(),
    routes: <String, WidgetBuilder>{
      'less': (BuildContext context) => StatefullGroup(),
      'photo': (BuildContext context) => PhotoAppDemo(),
    },
    initialRoute: '/',
    onGenerateRoute:(RouteSettings routeSettings){
      print('onGenerateRoute:$routeSettings');
      if(routeSettings.name =='less'){
        return MaterialPageRoute(builder: (context){
          return StatefullGroup();
        });
      }
    } ,
    onUnknownRoute: (RouteSettings routeSettings){
      print('onUnknownRoute:$routeSettings');
      return MaterialPageRoute(builder: (context){
        return PhotoAppDemo();
      });
    },
    localizationsDelegates: [
      GlobalMaterialLocalizations.delegate,
      GlobalWidgetsLocalizations.delegate,
      GlobalCupertinoLocalizations.delegate
    ],
    supportedLocales: [
      const Locale('zh','CH'),
      const Locale('en','US'),
    ],

    localeListResolutionCallback: (locales, supportedLocales) {
      print('当前系统语言环境:$locales');
      if (locales!.contains('zh')) {
        return Locale('zh');
      }
      return Locale('en');
    },
    // debugShowMaterialGrid: true,
    // showPerformanceOverlay: true,
    debugShowCheckedModeBanner: false,
  );
}